//获取当前时间进行判断
export const getTime = () => {
  let message = "";
  const hours = new Date().getHours();
  if (hours <= 6) {
    message = "晚上";
  } else if (hours <= 9) {
    message = "早上";
  } else if (hours <= 11) {
    message = "上午";
  } else if (hours <= 13) {
    message = "中午";
  } else if (hours <= 18) {
    message = "下午";
  } else {
    message = "晚上";
  }

  return message;
};
//2025年5月7日
export const formatDate = (date: Date) => {
  const year = date.getFullYear();
  const month = date.getMonth() + 1;
  const day = date.getDate();

  return `${year}年${month}月${day}日 `;
};
//14:41
export const times = (date: Date) => {
  const hour = date.getHours();
  const minute = date.getMinutes();
  return `${hour}:${minute}`;
};
// 判断时间段的函数  上午  下午  晚上
export const getTimeOfDay = () => {
  const now = new Date();
  const hours = now.getHours();

  if (hours >= 5 && hours < 12) {
    return "上午";
  } else if (hours >= 12 && hours < 18) {
    return "下午";
  } else {
    return "晚上";
  }
};
// 判断星期几的函数
export const getDayOfWeek = () => {
  const now = new Date();
  const dayIndex = now.getDay(); // 获取星期几的索引
  const days = [
    "星期日",
    "星期一",
    "星期二",
    "星期三",
    "星期四",
    "星期五",
    "星期六",
  ];
  return days[dayIndex]; // 根据索引返回星期几的名称
};
